package org.dei.perla.sys.core;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class AgentFactory{
		
	public static<T extends DefaultAgent>  T createNewInstance(Class<T> clazz){		
		try {
			Constructor<T> constructor =  clazz.getDeclaredConstructor(String.class);
			T retvalue = constructor.newInstance(clazz.getCanonicalName());
			return retvalue;
		} catch (SecurityException e) {
			//TODO aggiungere logging
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			//TODO aggiungere logging
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			//TODO aggiungere logging
			e.printStackTrace();
		} catch (InstantiationException e) {
			//TODO aggiungere logging
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			//TODO aggiungere logging
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			//TODO aggiungere logging
			e.printStackTrace();
		}
		return null;
	}
	
}

